package com.biz.primus.ms.oms.api;

import com.biz.primus.model.oms.vo.OmsOrderReturnVo;
import com.biz.primus.model.oms.vo.OmsOrderVo;
import com.biz.primus.model.oms.vo.OrderQueryVo;
import com.biz.primus.model.oms.vo.OrderReturnQueryVo;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.oms.service.core.OrderQueryService;
import com.biz.primus.ms.oms.service.core.OrderStateService;
import com.biz.primus.ms.oms.service.returns.OrderReturnQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yanweijin
 * @date 2017/11/25
 */

@RestController
@RequestMapping("soa/omsErpApi")
public class OmsErpApiController extends BaseApiController{


	@Autowired
	private OrderQueryService orderQueryService;

	@Autowired
	private OrderReturnQueryService orderReturnQueryService;

	@Autowired
	private OrderStateService orderStateService;


	@GetMapping("findOrders")
	public List<OmsOrderVo> findOrders(OrderQueryVo query){
		return orderQueryService.findOrders(query).getContent();
	}

	@GetMapping("findReturns")
	public List<OmsOrderReturnVo> findReturns(OrderReturnQueryVo query){
		return orderReturnQueryService.findReturns(query).getContent();
	}

	@GetMapping("orderDetail")
	public OmsOrderVo orderDetail(
			@RequestParam("depotCode") String depotCode,
			@RequestParam("code") String orderCode){
		return orderQueryService.orderQueryDetail(depotCode,orderCode);
	}

	@GetMapping("returnDetail")
	public OmsOrderReturnVo returnDetail(
			@RequestParam("depotCode") String depotCode,
			@RequestParam("code") String orderCode){
		return orderReturnQueryService.orderReturnQueryDetail(depotCode,orderCode);
	}


	@PostMapping("printOrder")
	public void printOrder(@RequestBody OrderStateService.OrderStateChangeRequest req){
		orderStateService.printOrder(req);
	}

	@PostMapping("outbound")
	public void outbound(@RequestBody OrderStateService.OrderStateChangeRequest req){
		orderStateService.outbound(req);
	}






}
